#!/usr/bin/env bash

##################### 获取工作目录 #####################
# 参考：http://www.gimoo.net/t/1502/54ea928e14fef.html
SOURCE="$0"
while [ -h "$SOURCE"  ]; do                              # resolve $SOURCE until the file is no longer a symlink
    DIR="$( cd -P "$( dirname "$SOURCE"  )" && pwd  )"
    SOURCE="$(readlink "$SOURCE")"
    [[ $SOURCE != /*  ]] && SOURCE="$DIR/$SOURCE"        # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE"  )" && cd .. && pwd  )"
#######################################################

app=$(basename $DIR)     # app="ems"

# /opt/ems 或 /mnt/sdc/opt/ems
workdir=$DIR             # workdir="/opt/$app"

echo "复制 $workdir/src/ems-archive/bin/copy_script.sh 到 $workdir/bin/copy_script.sh"
cp $workdir/src/ems-archive/bin/copy_script.sh $workdir/bin/copy_script.sh

echo "复制 $workdir/src/ems-archive/bin/build.sh 到 $workdir/bin/build.sh"
cp $workdir/src/ems-archive/bin/build.sh $workdir/bin/build.sh

echo "复制 $workdir/src/ems-archive/bin/clone.sh 到 $workdir/bin/clone.sh"
cp $workdir/src/ems-archive/bin/clone.sh $workdir/bin/clone.sh

echo "复制 $workdir/src/ems-archive/bin/pull.sh 到 $workdir/bin/pull.sh"
cp $workdir/src/ems-archive/bin/pull.sh $workdir/bin/pull.sh

echo "复制 $workdir/src/ems-archive/bin/control.sh 到 $workdir/bin/control.sh"
cp $workdir/src/ems-archive/bin/control.sh $workdir/bin/control.sh

echo "复制 $workdir/src/ems-archive/bin/deploy.sh 到 $workdir/bin/deploy.sh"
cp $workdir/src/ems-archive/bin/deploy.sh $workdir/bin/deploy.sh

echo "复制 $workdir/src/ems-archive/bin/redeploy.sh 到 $workdir/bin/redeploy.sh"
cp $workdir/src/ems-archive/bin/redeploy.sh $workdir/bin/redeploy.sh

echo "复制 $workdir/src/ems-archive/bin/export_tdengine.sh 到 $workdir/bin/export_tdengine.sh"
cp $workdir/src/ems-archive/bin/export_tdengine.sh $workdir/bin/export_tdengine.sh

echo "复制 $workdir/src/ems-archive/bin/test_export.sh 到 $workdir/bin/test_export.sh"
cp $workdir/src/ems-archive/bin/test_export.sh $workdir/bin/test_export.sh

echo "复制 $workdir/src/ems-archive/src/main/resources/application-prod.yml 到 $workdir/module/archive/config/application.yml"
cp $workdir/src/ems-archive/src/main/resources/application.yml $workdir/module/archive/config/application.yml

echo "复制 $workdir/src/ems-archive/src/main/resources/application-prod.yml 到 $workdir/module/archive/config/application-prod.yml"
cp $workdir/src/ems-archive/src/main/resources/application-prod.yml $workdir/module/archive/config/application-prod.yml

echo "复制 $workdir/src/ems-archive/src/main/resources/application-back.yml 到 $workdir/module/archive/config/application-back.yml"
cp $workdir/src/ems-archive/src/main/resources/application-back.yml $workdir/module/archive/config/application-back.yml



